﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using Contract;
using System.Net;

namespace client
{
    public partial class UserProperty : Form
    {
        string PCN;
        string Psw;
        MyUser us;
        public UserProperty(string pcn, string password)
        {
            PCN = pcn;
            Psw = password;
            InitializeComponent();
            loadUserInfo();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Cpassword cp = new Cpassword(PCN);
            cp.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DeUser du = new DeUser(PCN);
            du.Show();
        }

        private void loadUserInfo()
        {
            NetTcpBinding binding = new NetTcpBinding();
            binding.TransferMode = TransferMode.Streamed;
            binding.SendTimeout = TimeSpan.MaxValue;
            binding.MaxReceivedMessageSize = 9223372036854775807;
            MessageBox.Show("net.tcp://" + Dns.GetHostAddresses(Environment.MachineName)[2] + ":5000/DataUploader");
            EndpointAddress address = new EndpointAddress("net.tcp://" + Dns.GetHostAddresses(Environment.MachineName)[2] + ":5000/DataUploader");

            ChannelFactory<IDataUploader> channel = new ChannelFactory<IDataUploader>(binding, address);
            IDataUploader Proxy = channel.CreateChannel();
            us=Proxy.Login(new MyUser {PCN = this.PCN,Password = this.Psw});
            label5.Text = us.PCN;
            label6.Text = us.Fname;
            label7.Text = us.Lname;
            label8.Text = us.Email;
        }
    }
}
